package offer;

import java.util.HashSet;

public class SingleNumber_56 {
    public int singleNumber(int[] nums) {

        HashSet<Integer> set = new HashSet<>();
        long sumset = 0;
        long sumnum = 0;
        for (int num : nums) {
            sumnum += num;
            if(set.contains(num)){
                continue;
            }
            sumset += num;
            set.add(num);
        }

        return (int) (sumset * 3 - sumnum)/2;

    }
}
